package com.feel.controller;

import com.feel.pojo.RespBean;
import com.feel.service.AppointmentService;
import com.feel.service.DepartmentService;
import com.feel.service.ServicePartsService;
import com.feel.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * @Author: 刘永钦
 * @Date: 2024-09-06-14:27
 * @Description:
 */
@RestController
@RequestMapping("/admin/echarts")
public class EchartsController {
    @Autowired
    private DepartmentService departmentService;

    @Autowired
    private ServicePartsService ServicePartsService;

    @Autowired
    private UserService userService;

    @Autowired
    private AppointmentService appointmentService;

    /**
     * 获取部门人员分配情况
     * 返回值要是{ value: 1048, name: '家电维修' }形式的列表
     */
    @GetMapping("/department")
    RespBean getDepartmentInfo() {
        List<Map<String, Object>> departmentEcharts = departmentService.getDepartmentEcharts();
        return RespBean.ok("查询成功",departmentEcharts);
    }

    /**
     * 获得配件配件使用前5
     * 格式：map{x:[],y:[]}
     */
    @GetMapping("/parts")
    RespBean getPartsInfo() {
        Map<String, Object> map = ServicePartsService.getPartsEchartsInfo();
        return RespBean.ok("查询成功", map);
    }

    /**
     * 获取用户数量
     */
    @GetMapping("/userNumber")
    RespBean getUserNumber() {
        Integer number = userService.getUserNumber("user");
        return RespBean.ok("查询成功", number);
    }

    /**
     * 获取男女比例
     * {m:'',n:''}
     */
    @GetMapping("/sex")
    RespBean getSexRatio() {
        Map<String, Object> map = userService.getSexRatio();
        return RespBean.ok("查询成功", map);
    }

    /**
     * 查询订单数量
     */
    @GetMapping("/appointment")
    RespBean getAppointmentNumber() {
        Integer number = appointmentService.getAppointmentNumber();
        return RespBean.ok("查询成功",number);
    }
}
